const {Layout, Menu, Icon} = antd;
const {Sider} = Layout;
const SubMenu = Menu.SubMenu;

class LeftMenu extends React.Component {
    render() {
        // var arr = UserMenu;
        const arr = [{
            "JobID": "1001",
            "MenuID": "1001",
            "MenuPID": "-1",
            "MenuName": "首页",
            "Url": "page",
            "ImageUrl": "index",
            "IconClass": "left_project_icon_sy",
            "IsHomePage": "1",
            "IsShow": "1",
            "ListIndex": "5",
            "Levels": "1",
            "IsHasChild": "0"
        }, {
            "JobID": "1002",
            "MenuID": "1002",
            "MenuPID": "-1",
            "MenuName": "系统管理",
            "Url": "",
            "ImageUrl": "",
            "IconClass": "left_project_icon_kh",
            "IsHomePage": "1",
            "IsShow": "1",
            "ListIndex": "6",
            "Levels": "1",
            "IsHasChild": "1"
        }, {
            "JobID": "1003",
            "MenuID": "1003",
            "MenuPID": "-1",
            "MenuName": "系统设置",
            "Url": "",
            "ImageUrl": "",
            "IconClass": "left_project_icon_ac",
            "IsHomePage": "1",
            "IsShow": "1",
            "ListIndex": "7",
            "Levels": "1",
            "IsHasChild": "1"
        }, {
            "JobID": "1004",
            "MenuID": "1004",
            "MenuPID": "-1",
            "MenuName": "修改密码",
            "Url": "",
            "ImageUrl": "",
            "IconClass": "left_project_icon_qd",
            "IsHomePage": "1",
            "IsShow": "1",
            "ListIndex": "8",
            "Levels": "1",
            "IsHasChild": "0"
        },{
            "JobID": "1002-1",
            "MenuID": "1002-1",
            "MenuPID": "1002",
            "MenuName": "用户管理",
            "Url": "",
            "ImageUrl": "",
            "IconClass": "",
            "IsHomePage": "1",
            "IsShow": "1",
            "ListIndex": "6",
            "Levels": "1",
            "IsHasChild": "0"
        },
        {
            "JobID": "1002-2",
            "MenuID": "1002-2",
            "MenuPID": "1002",
            "MenuName": "角色管理",
            "Url": "",
            "ImageUrl": "",
            "IconClass": "",
            "IsHomePage": "1",
            "IsShow": "1",
            "ListIndex": "6",
            "Levels": "1",
            "IsHasChild": "0"
        },
        {
           "JobID": "1002-3",
            "MenuID": "1002-3",
            "MenuPID": "1002",
            "MenuName": "功能权限管理",
            "Url": "",
            "ImageUrl": "",
            "IconClass": "",
            "IsHomePage": "1",
            "IsShow": "1",
            "ListIndex": "6",
            "Levels": "1",
            "IsHasChild": "0"
        },
        {
            "JobID": "1002-4",
            "MenuID": "1002-4",
            "MenuPID": "1002",
            "MenuName": "数据权限管理",
            "Url": "",
            "ImageUrl": "",
            "IconClass": "",
            "IsHomePage": "1",
            "IsShow": "1",
            "ListIndex": "6",
            "Levels": "1",
            "IsHasChild": "0"
        },
        {
            "JobID": "1003-1",
            "MenuID": "1003-1",
            "MenuPID": "1003",
            "MenuName": "基础数据",
            "Url": "",
            "ImageUrl": "",
            "IconClass": "",
            "IsHomePage": "1",
            "IsShow": "1",
            "ListIndex": "6",
            "Levels": "1",
            "IsHasChild": "0"
        },
        {
            "JobID": "1003-2",
            "MenuID": "1003-2",
            "MenuPID": "1003",
            "MenuName": "日志管理",
            "Url": "",
            "ImageUrl": "",
            "IconClass": "",
            "IsHomePage": "1",
            "IsShow": "1",
            "ListIndex": "6",
            "Levels": "1",
            "IsHasChild": "0"
        },
        {
            "JobID": "1003-3",
            "MenuID": "1003-3",
            "MenuPID": "1003",
            "MenuName": "参数管理",
            "Url": "",
            "ImageUrl": "",
            "IconClass": "",
            "IsHomePage": "1",
            "IsShow": "1",
            "ListIndex": "6",
            "Levels": "1",
            "IsHasChild": "0"
        }
        ];
        return (
            <div>
                <Sider style={{overflow: 'auto', height: '100vh', position: 'fixed', left: 0, background: '#ffffff'}}>

                    {/*<Menu theme="light" mode="vertical" defaultSelectedKeys={[CurrMenu.MenuID]}>*/}
                    <Menu theme="light" mode="vertical" defaultSelectedKeys={[]}>
                        {arr.map((d, num) =>
                            d.MenuPID == "-1" && d.IsShow == "1" ?
                                d.IsHasChild == "1" ?
                                    <SubMenu key={d.MenuID}
                                             title={<span><Icon type="team"/><span>{d.MenuName}</span></span>}>
                                        {arr.map((_d, _num) =>
                                            _d.MenuPID == d.MenuID && _d.IsShow == "1" ?
                                                <Menu.Item key={_d.MenuID}>
                                                    <a href={_d.Url}>
                                                        <span className="nav-text"> {_d.MenuName}</span>
                                                    </a>

                                                </Menu.Item>
                                                :
                                                ""
                                        )}
                                    </SubMenu> :
                                    <Menu.Item key={d.MenuID}>
                                        <a href={d.Url}>
                                            <Icon type="home"/>
                                            <span className="nav-text">{d.MenuName}</span>
                                        </a>
                                    </Menu.Item>
                                :
                                ""
                        )}
                    </Menu>

                </Sider>
            </div>
        );
    }
}